/*
 * @Author: nqx2007 fenglimima334@163.com
 * @Date: 2023-12-10 13:06:47
 * @LastEditors: nqx2007 fenglimima334@163.com
 * @LastEditTime: 2023-12-12 12:03:40
 * @FilePath: /operator-manager/mock/account_role_manage.ts
 * @Description: 账号和角色管理的Mock数据
 */

import {
  AccountTableEnum,
  RoleTableEnum,
} from '../src/pages/AccountAccessManage/type.d';
import { baseApiPrefix } from '../src/services';

export default {
  //获取账号列表
  [`POST ${baseApiPrefix}/user/page`]: (req: any, res: any) => {
    res.json({
      success: true,
      data: {
        dataList: [
          {
            id: 1,
            [AccountTableEnum.NAME]: '嘻嘻哈哈',
            [AccountTableEnum.PHONE]: '111111111',
            [AccountTableEnum.ROLE_NAME]: '角色一',
            [AccountTableEnum.ROLE_ID]: 1,
            [AccountTableEnum.STATUS]: 0,
          },
          {
            id: 2,
            [AccountTableEnum.NAME]: '嘻嘻哈哈',
            [AccountTableEnum.PHONE]: '111111111',
            [AccountTableEnum.ROLE_NAME]: '角色一',
            [AccountTableEnum.ROLE_ID]: 2,
            [AccountTableEnum.STATUS]: 1,
          },
        ],
        totalResult: 26,
      },
      message: '',
    });
  },
  //获取不分页的角色列表
  [`${baseApiPrefix}/role/query_list`]: (req: any, res: any) => {
    res.json({
      success: true,
      data: [
        {
          id: 1,
          name: '角色一',
        },
        {
          id: 12,
          name: '角色二',
        },
      ],
      message: '',
    });
  },
  //创建账号
  [`POST ${baseApiPrefix}/user`]: (req: any, res: any) => {
    res.json({
      success: true,
      data: true,
      message: '',
    });
  },
  //编辑账号
  [`PUT ${baseApiPrefix}/user`]: (req: any, res: any) => {
    res.json({
      success: true,
      data: true,
      message: '',
    });
  },
  //获取角色列表
  [`POST ${baseApiPrefix}/role/page`]: (req: any, res: any) => {
    res.json({
      success: true,
      data: {
        dataList: [
          {
            [RoleTableEnum.ID]: 1,
            [RoleTableEnum.ROLE_NAME]: '超级管理员',
            [RoleTableEnum.ROLE_DESC]: '拥有所有的权限',
            [RoleTableEnum.CREATE_TIME]: '',
          },
          {
            [RoleTableEnum.ID]: 2,
            [RoleTableEnum.ROLE_NAME]: '普通角色',
            [RoleTableEnum.ROLE_DESC]: '拥有配置的权限',
            [RoleTableEnum.CREATE_TIME]: '',
          },
        ],
        totalResult: 2,
      },
      errorCode: 0,
    });
  },
  // 获取角色权限树
  [`${baseApiPrefix}/menu/list`]: (req: any, res: any) => {
    res.json({
      success: true,
      data: [
        {
          name: '所有',
          id: '0',
          childrenList: [
            {
              name: '客户管理',
              id: '0-1',
              childrenList: [
                {
                  name: '客户列表',
                  id: '0-1-0',
                },
              ],
            },
            {
              name: '商家管理',
              id: '0-2',
              childrenList: [
                {
                  name: '入驻审核',
                  id: '0-2-0',
                },
                {
                  name: '审核',
                  id: '0-2-1',
                },
              ],
            },
          ],
        },
      ],
      errorCode: 0,
    });
  },
  // 获取角色详情
  [`${baseApiPrefix}/role/:id`]: (req: any, res: any) => {
    res.json({
      success: true,
      data: {
        [RoleTableEnum.ID]: 2,
        [RoleTableEnum.ROLE_NAME]: '普通角色',
        [RoleTableEnum.ROLE_DESC]: '',
        [RoleTableEnum.ACCESS_RANGE]: ['0-1', '0-2-0'],
      },
      errorCode: 0,
    });
  },
};
